package com.oauth2demo.utils;

import com.oauth2demo.doman.SysUser;

/**
 * <h3>oauth2Demo</h3>
 * <p>当前用户</p>
 *
 * @author gdw
 * @since 2024-07-04 15:19:20
 */
public class AdministratorThreadLocal {
    private static ThreadLocal<SysUser> administratorThreadLocal = new ThreadLocal<>();

    public static void setAdministrator(SysUser sysUser) {
        administratorThreadLocal.set(sysUser);
    }

    public static SysUser getAdministrator() {
        return administratorThreadLocal.get();
    }

    public static void removeAdministrator() {
        administratorThreadLocal.remove();
    }

    public static String getAdministratorName(){
        return administratorThreadLocal.get().getUserName();
    }
}
